package com.xbongbong.saas.service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xbongbong.distributor.dto.DistributorEditAttrUpdateDTO;
import com.xbongbong.distributor.vo.DistributorEditAttrUpdateVO;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.pojo.FieldAttrEntityForImport;
import com.xbongbong.paas.pojo.dto.FormDataAddDTO;
import com.xbongbong.paas.pojo.dto.FormDataListDTO;
import com.xbongbong.paas.pojo.dto.ImportFormDataDTO;
import com.xbongbong.paas.pojo.dto.SaasFormSaveDTO;
import com.xbongbong.paas.pojo.dto.ValidateDataDTO;
import com.xbongbong.paas.pojo.imports.CellTitlePojo;
import com.xbongbong.paas.pojo.imports.RowGroupPojo;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.applist.pojo.vo.ListAppVO;
import com.xbongbong.pro.businessdata.pojo.dto.FormatExplainDTO;
import com.xbongbong.distributor.dto.DistributorDeleteBatchDTO;
import com.xbongbong.distributor.vo.DistributorDeleteBatchVO;
import com.xbongbong.pro.formdata.pojo.dto.SaasAnalysisDataDTO;

import java.util.List;

/**
 * @author xinpeng.jiang
 * @version V1.0
 * @date 2020/12/22 16:10
 * @since V1.0
 */
public interface DistributorManageService {

    /**
     * 格式化解释字段
     * @param formatExplainDTO
     * @throws XbbException
     * @author xinpeng.jiang
     * @date 2020/12/22 16:13
     * @version 1.0
     */
    void formatAddExplain(FormatExplainDTO formatExplainDTO) throws XbbException;
    /**
     * 经销商保存前saas特殊校验
     *
     * @param validateDataDTO saas特殊校验数据入参
     * @throws XbbException 业务异常
     * @author feng.zheng
     * @date 2019/1/18
     */
    void beforeSave(ValidateDataDTO validateDataDTO) throws XbbException;
    /**
     * 经销商保存后处理逻辑
     *
     * @param saasFormSaveDTO
     * @throws XbbException 业务异常
     * @author feng.zheng
     * @date 2019/1/18
     */
    void afterSave(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;

    /**
     * 校验联系人
     * @param corpid
     * @param contactArray
     * @param dataId
     * @param name
     * @param validateDataDTO
     * @throws XbbException
     * @author xinpeng.jiang
     * @date 2020/12/31 11:22
     * @version 1.0
     */
    void verifyContact(String corpid, JSONArray contactArray, Long dataId, String name, ValidateDataDTO validateDataDTO) throws XbbException;

    /**
     * 批量删除
     * @param distributorDeleteBatchDTO
     * @return com.xbongbong.distributor.vo.DistributorDeleteBatchVO
     * @throws XbbException
     * @author xinpeng.jiang
     * @date 2021/1/5 15:38
     * @version 1.0
     */
    DistributorDeleteBatchVO deleteBatch(DistributorDeleteBatchDTO distributorDeleteBatchDTO) throws XbbException;

    /**
     * 批量更新
     * @param distributorEditAttrUpdateDTO
     * @return com.xbongbong.distributor.vo.DistributorEditAttrUpdateVO
     * @throws XbbException
     * @author xinpeng.jiang
     * @date 2021/1/6 13:59
     * @version 1.0
     */
    DistributorEditAttrUpdateVO batchEditAttr(DistributorEditAttrUpdateDTO distributorEditAttrUpdateDTO) throws XbbException;

    /**
     * 编辑时将获取数据格式化
     *
     * @param saasAnalysisDataDTO saas编辑数据
     * @param result 要返回的jsonobject
     * @throws XbbException 业务异常
     * @author feng.zheng
     * @date 2019/1/22 15:28
     */
    void formatData(SaasAnalysisDataDTO saasAnalysisDataDTO, JSONObject result) throws XbbException;

    /**
     * 编辑时格式化解释
     *
     * @param formatExplainDTO 入参
     * @throws XbbException 异常
     * @author long.rao
     * @date 2019-06-15 13:59
     */
    void formatUpdateExplain(FormatExplainDTO formatExplainDTO) throws XbbException;

    /**
     * 移动端列表页转换
     * @param formDataListDTO
     * @param esEntities
     * @param totalCount
     * @return
     */
    ListAppVO formatDistributorAppList(FormDataListDTO formDataListDTO, List<PaasFormDataEntityExt> esEntities, Integer totalCount) throws XbbException;

    /**
     * 导入格式转换
     * @param importFormDataDTO
     * @param titlePojoList
     * @param rowGroupPojo
     * @param fieldAttrList
     * @return com.xbongbong.paas.pojo.dto.FormDataAddDTO
     * @throws XbbException
     * @author xinpeng.jiang
     * @date 2021/1/18 20:31
     * @version 1.0
     */
    FormDataAddDTO formatExcelValue(ImportFormDataDTO importFormDataDTO, List<CellTitlePojo> titlePojoList, RowGroupPojo rowGroupPojo, List<FieldAttrEntityForImport> fieldAttrList) throws XbbException;

    /**
     * 导出格式转换
     * @param paasFormDataESList
     * @param formDataListDTO
     * @param fieldAttrList
     * @param businessType
     * @throws XbbException
     * @author xinpeng.jiang
     * @date 2021/1/19 19:16
     * @version 1.0
     */
    void formatExportValue(List<PaasFormDataEntityExt> paasFormDataESList, FormDataListDTO formDataListDTO, List<FieldAttrEntityForImport> fieldAttrList, Integer businessType) throws XbbException;
}
